package com.qkl.xiatang.app.utils;

import com.qkl.xiatang.app.utils.appenum.AppUserDutiesEnum;
import com.qkl.xiatang.app.utils.appenum.MessageTypeEnum;

import java.util.ArrayList;
import java.util.List;

public class MessageTypeUtils {

    public static List<Integer> toMessageList(String userIdentity){
        List<Integer> list = new ArrayList<>();
        if(AppUserDutiesEnum.isWeigh(userIdentity)){
            list.add(MessageTypeEnum.WEIGH_FEED.getType());
            list.add(MessageTypeEnum.WEIGH_ZOO.getType());
        }
        if(AppUserDutiesEnum.isFeed(userIdentity)){
            list.add(MessageTypeEnum.FEED.getType());
            list.add(MessageTypeEnum.ZOO.getType());
        }
        if(AppUserDutiesEnum.isCheck(userIdentity)){
            list.add(MessageTypeEnum.CHECK.getType());
        }
        if(AppUserDutiesEnum.isAlloc(userIdentity) || AppUserDutiesEnum.isAdmin(userIdentity) || AppUserDutiesEnum.isHolder(userIdentity) || AppUserDutiesEnum.isObserve(userIdentity)){
            //list.add(MessageTypeEnum.ADMIN.getType());
            list.clear();
            list.addAll(MessageTypeEnum.allTypeList());
        }
        if(AppUserDutiesEnum.isDuties(userIdentity) && !list.contains(MessageTypeEnum.ADMIN.getType())){
            list.add(MessageTypeEnum.ADMIN.getType());//系统消息所有人可查
        }
        return list;
    }

}
